package app.view.component 
{
	import com.hutra.bitmap.MovieBitmap;
	import com.temple.core.CoreMovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	/**
	 * ...
	 * @author PHANCUONG87
	 */
	public class BackShaded extends CoreMovieClip
	{
		private var _count:int = 0;
		public function BackShaded() {
			visible = false;
			addEventListener(Event.ADDED_TO_STAGE, onInital);
		}
		public function onInital(evt:Event):void {
			stage.addEventListener( Event.RESIZE, onResize );	
			createBackGround();
			onResize(evt);
		}
		private function createBackGround():void 
		{
			var backgroundForm:Sprite = new Sprite();	
			backgroundForm.name = "transparentBg";
			
			var mWidth:Number = Main.ROOT.stage.stageWidth + 4;
			var mHeight:Number = Main.ROOT.stage.stageHeight + 4;
			
			var posX:Number =0// -mWidth / 2;
			var posY:Number = 0// -mHeight / 2;
			
			backgroundForm.graphics.beginFill(0x000000, 0.7);
			backgroundForm.graphics.drawRect(posX, posY, mWidth, mHeight);
			backgroundForm.graphics.endFill();	
			this.addChild(backgroundForm);
		}
		
		public function onResize(evt:Event):void {
			width = (width > stage.stageWidth)?width:stage.stageWidth;
			height = (height > stage.stageHeight)?height:stage.stageHeight;
			
			x = Math.round((stage.stageWidth - width) / 2);
			y = Math.round((stage.stageHeight - height) / 2);
		}
		
		public function hide():void {
			_count--;
			if (_count <= 0) {
				visible = false;
				_count = 0;
			}
			
		}
		
		public function show():void {
			_count++;
			visible = true;
		}
	}

}